package com.icbc.springcloud.controller;

import com.icbc.springcloud.pojo.Dept;
import com.icbc.springcloud.service.DeptClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class DeptConsumerController {
    /*
    * 消费者服务里面不应该有service层
    * 将restTemplate注册到spring中，然后直接调用就好了
    * （url，实体：Map，Class<T> responseType）
    * */
    @Autowired
    private DeptClientService service=null;


    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id")int id){
       return this.service.queryById(id);
    }

    @RequestMapping("/consumer/dept/get/all")
    public List<Dept> getAll(){
        return this.service.queryAll();
    }

    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept){
        return this.service.addDept(dept);
    }

/*    @RequestMapping("/consumer/dept/test/add")
    public boolean add_test(Dept dept){
        log.info(dept.toString());
        return restTemplate.getForObject(REST_URL_PREFIX+"/dept/add"+dept.getDname(),Boolean.class);
    }*/


}
